package com.yuyou.tas.lesson.service;

import com.yuyou.tas.service.api.lesson.dto.LessonDetailDTO;
import com.yuyou.tas.service.api.lesson.dto.LessonPageDTO;
import com.yuyou.tas.service.api.lesson.dto.LessonStatisticDTO;
import com.yuyou.tas.service.api.lesson.entity.Lesson;
import com.yuyou.tas.util.bean.Pagination;
import com.yuyou.tas.util.bean.ResBoolSimpleInfo;
import com.yuyou.tas.util.bean.ResourceObj;

import java.util.List;


public interface ILessonService{
    int deleteByPrimaryKey(Long id);

    int insert(Lesson record);

    Lesson selectByPrimaryKey(Long id);
    
    /**
     * 
     * @param id
     * @param authOrganizationId
     * @return
     */
    Lesson selectByPKandOrgan(Long id,Long authOrganizationId);

    int updateByPrimaryKeySelective(Lesson record);
    

    
    /**
     * 新增修改课程
     * @param record
     * @param userId
     * @return
     * @throws Exception
     */
    ResBoolSimpleInfo<LessonDetailDTO> addOrUpLesson(Lesson record,Long userId)throws Exception;
    
    /**
     * 课程列表分页
     * @param queryPgn
     * @return
     */
    int findLessonCount(Pagination<LessonPageDTO> queryPgn);
    
    /**
     * 课程列表分页
     * @param queryPgn
     * @return
     */
    List<LessonPageDTO> findLessonPageList(Pagination<LessonPageDTO> queryPgn);
    
    /**
     * 找出已发布的，未同步的OID不为空的课程
     * @param authOrganizationId
     * @return
     */
    List<Lesson> findPubLessonByOrganId(Long authOrganizationId);
    
    /**
     * 课程详情
     * @param id
     * @param authOrganizationId
     * @param userId
     * @return
     * @throws Exception
     */
    ResBoolSimpleInfo<LessonDetailDTO> detailLesson(Long id,Long authOrganizationId,Long userId)throws Exception;
    
    /**
     * 发布课程
     * @param id
     * @param status
     * @param authOrganizationId
     * @param userId
     * @return
     * @throws Exception
     */
    ResBoolSimpleInfo<String> publishLesson(Long id,int status,Long authOrganizationId,Long userId)throws Exception;
    
    /**
     * 根据组织ID和OID查询
     * @param oId
     * @param authOrganizationId
     * @return
     */
    Lesson selectByOrgan7OId(Long oId,Long authOrganizationId);
    
    /**
     * 根据组织ID和OID删除
     * @param oId
     * @param authOrganizationId
     * @return
     */
    ResBoolSimpleInfo<String> delByOrgan7OId(Long oId,Long authOrganizationId);
    
    /**
     * 根据组织ID和OID删除
     * @param oId
     * @param authOrganizationId
     * @return
     */
    ResBoolSimpleInfo<String> delByOrgan7OIds(List<Long> oId,Long authOrganizationId);

    /**
     * 校验课程是否发布
     * @param lessonId
     * @throws Exception
     */
	void checkPublicLesson(Long lessonId)throws Exception;
	
	/**
	 * 校验课程是否发布
	 * @param l
	 * @throws Exception
	 */
	void checkPublicLesson(Lesson l)throws Exception;

	void validate(boolean checkLesson,Long lessonId, List<Long> lessonChapterIds,
			List<Long> baseChapterIds, Long userId) throws Exception;

	/**
	 * 班级复制课程
	 * @param publish
	 * @param lessonClassId
	 * @param pId
	 * @param userId
	 * @param resourceObj
	 * @return
	 * @throws Exception
	 */
	ResBoolSimpleInfo<String> copyClassLesson(boolean publish,Long lessonClassId,Long pId, Long userId,ResourceObj resourceObj) throws Exception;

	/**
	 * 外部数据源同步课程信息
	 * @param list
	 * @return
	 * @throws Exception
	 */
	ResBoolSimpleInfo<String> syncLessons(List<Lesson> list) throws Exception;

    int findLessonStatisticCount(Pagination<LessonStatisticDTO> queryPgn);

    List<LessonStatisticDTO> findLessonStatisticPageList(Pagination<LessonStatisticDTO> queryPgn);

    /**
     * 删除课程
     * @param id
     * @param isSystem
     * @return
     */
    ResBoolSimpleInfo<String> delLesson(Long id , boolean isSystem);
    
    /**
     * 取消发布课程
     * @param organizationId
     * @param id
     * @return
     */
    ResBoolSimpleInfo<String> cancelPublicLesson(Long organizationId,Long id)throws Exception;

    /**
     * 升级同步课程的所有班级讲次
     * @param lessonId
     * @param lessonOId
     * @param authOrganizationId
     * @return
     * @throws Exception
     */
	ResBoolSimpleInfo<String> upGradeClassByLesson(Long lessonId, Long lessonOId,
			Long authOrganizationId) throws Exception;



    Lesson selectByClassId(Long classId);

}